<?php

namespace app\web\controller;

use app\web\service\InvoiceService;

class InvoiceController extends CommonController
{
    // 获取开发票的订单列表
    public function getInvoiceList(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(InvoiceService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getList();
        return $this->return_result($this->returnData);
    }

    // 添加发票
    public function toAddInvoice(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(InvoiceService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toAdd();
        return $this->return_result($this->returnData);
    }

    // 发票的详细内容
    public function getInvoiceHistory(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(InvoiceService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getHistory();
        return $this->return_result($this->returnData);
    }

    // 发票的详细内容
    public function getInvoiceDetail(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(InvoiceService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getDetail();
        return $this->return_result($this->returnData);
    }

}